import routes from '../routes.js'
const uyghurmodal = {
  toast(obj){
    var modal = weex.requireModule('modal')
    modal.toast(obj)
    // window.location.href = url;
  },
  alert(obj,call){
    var modal = weex.requireModule('modal')
    modal.alert(obj, call)
    // window.location.href = url;
  },
  confirm(obj,call){
    var modal = weex.requireModule('modal')
    modal.confirm(obj, function(res){
      if(obj.okTitle == res){
          call('YES')
      }else{
          call('NO')
      }
    })
  },
  prompt(obj,call){
    var modal = weex.requireModule('modal')
    modal.prompt(obj, call)
    // window.location.href = url;
  }

}

// 定义user模块的元 (meta) 信息.
const meta = {
  uyghurmodal: [{
    name: 'toast',
    args: ['object']
  },
  {
    name: 'alert',
    args: ['object','function']
  },
  {
    name: 'confirm',
    args: ['object','function']
  },
  {
    name: 'prompt',
    args: ['object','function']
  },

  ]
}

export default {
  init (Weex) {
    // 注册这个模块，最后一个参数是模块的元信息.
    Weex.registerApiModule('uyghurmodal', uyghurmodal, meta)
    // console.log("注册中");
  }
}
